import { defHttp } from '/@/utils/request'

interface GetRoleListParams extends BaseParams {
  name?: string
  status?: 0 | 1
}
export const getRoleListApi = (params: GetRoleListParams) => {
  return defHttp.get<BaseResponseWithArray<defs.common.Role>>({
    url: '/api/role',
    params,
  })
}

export const addRoleApi = (data: Partial<defs.common.RoleCreateBody>) => {
  return defHttp.post<defs.common.Role>({ url: '/api/role', data })
}

export const updateRoleApi = (id: number, data: Partial<defs.common.RoleUpdateBody>) => {
  return defHttp.put<boolean>({ url: `/api/role/${id}`, data })
}

export const deleteRoleApi = (id: string) => {
  return defHttp.delete<number>({ url: `/api/role/${id}` })
}

export const getAllRoleListApi = () => {
  return defHttp.get<defs.common.Role[]>({
    url: '/api/role/all',
    params: { status: 1 },
  })
}
